package com.yiwei.hdb.util;

import android.app.Activity;
import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.widget.TextView;

import com.yiwei.hdb.R;

import java.util.Timer;
import java.util.TimerTask;

/**
 * Created by xsooy-pc on 2017/5/5.
 */

public class FlashingTextUtil {

    /**
     * 字体闪烁
     */
    int clo = 0;

    public  void spark(final Context context, final Activity activity, final TextView tv) {
        Timer timer = new Timer();

        TimerTask taskcc = new TimerTask() {
            public void run() {
                activity.runOnUiThread(new Runnable() {

                    public void run() {
                        if (clo == 0) {
                            clo = 1;
                            tv.setTextColor(ContextCompat.getColor(context, R.color.yellow));
                        } else {
                            clo = 0;
                            tv.setTextColor(ContextCompat.getColor(context, R.color.red));
                        }
                    }
                });
            }
        };
        timer.schedule(taskcc, 1, 400);
    }
}
